package com.ymttest.database.sqlwapper.sqdistributor;

import java.util.HashMap;
import java.util.List;

import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.sqdistributor.CommisionRate;

public class CommisionRateWrapper {
	
	SqlManager manager;

	public CommisionRateWrapper() {
		manager = new SqlManager("sqdistributor");
	}

	@SuppressWarnings("unchecked")
	public CommisionRate selectByPrimaryKey(Long id) {

		CommisionRate commisionRate = null;
		List<CommisionRate> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqdistributor.CommisionRateMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0) {
			commisionRate = result.get(0);
		}

		return commisionRate;
	}
	
	@SuppressWarnings("unchecked")
	public List<CommisionRate> selectByConfigId(Long configId) {

		List<CommisionRate> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqdistributor.CommisionRateMapper.selectByConfigId",
						configId);
		manager.commit();

		if (result.size() == 0) {
			Logger.comment("commision_rate没有数据");
		}

		return result;
	}
	
	@SuppressWarnings("unchecked")
	public CommisionRate selectByConfigIdAndLevel(Long configId, Integer level) {

		HashMap<String, Object> map = new HashMap<>();
		
		map.put("distribution_config_id", configId);
		map.put("distributor_level_index", level);
		
		List<CommisionRate> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqdistributor.CommisionRateMapper.selectByConfigIdAndLevel",
						map);
		manager.commit();

		if (result.size() == 0) {
			Logger.comment("commision_rate没有数据");
			return null;
		}

		return result.get(0);
	}
	
	public static void main(String[] args) {
		
		CommisionRateWrapper test = new CommisionRateWrapper();
		
//		SellerLevelHistory sellerLevelHistory = new SellerLevelHistory();
//		
//		sellerLevelHistory.setDDate(YMTDateUtil.getDate());
//		sellerLevelHistory.setSellerID(24635724);
//		sellerLevelHistory.setUpdateTime(YMTDateUtil.getDate());
//		sellerLevelHistory.setUnconfirm_amount(BigDecimal.TEN);
//		
		System.out.println(test.selectByPrimaryKey(4L));
	}
}
